#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require

#include "../../../../core/shader_std.h"
#include "../../../../core/shader_built_in_functions.h"
#include "../../../../core/shader_color.h"

layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inWdigths;



layout(push_constant, scalar) uniform DRAWPROP_push_constants {
	S_ConstPush_2DPolygonElement const_push;
};

layout(std140, binding = DEF_BINDING_PROJECT) uniform U_Matrix0 {
	mat4 mat_ProjecView;
};

layout(std430, set = 1, binding = 1, scalar, column_major) readonly buffer U_Matrix1 {
	mat3 tranformG[];
};
layout(std430, set = 1, binding = 2, scalar, column_major) readonly buffer U_Matrix2 {
	mat3 tranformL[];
};

layout(std430, set = 2, binding = 1, scalar) readonly buffer U_Matrix3 {
	uvec2 elementColor[];
};



out gl_PerVertex {
	vec4	gl_Position;
};
layout(location = 0) out vec4 vColor;


void main(void){
	mat3 matG = tranformG[const_push.m_Offset_TranformG];
	mat3 matL = tranformL[const_push.m_Offset_TranformL + gl_DrawID];
	uvec2 shaderPack = elementColor[const_push.m_Offset_Color + gl_DrawID];
	vColor = f_glsl_buildColor(shaderPack.x);
	
	vec2 vert = inPos * inWdigths;
	vec4 v = vec4(matG * matL * vec3(vert, 1.0), 1.0);
	
	gl_Position = mat_ProjecView * v;
}



